package com.mengxuegu.security;

import com.mengxuegu.web.entities.SysUser;
import com.mengxuegu.web.service.SysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * @author william
 * @create 2021-07-03 16:10
 **/
@Component("customUserDetailsService")
public class CustomUserDetailsService extends AbstractUserDetailsService {
    Logger logger = LoggerFactory.getLogger(CustomUserDetailsService.class);
    @Autowired
    PasswordEncoder passwordEncoder;

    @Autowired
    private SysUserService sysUserService;
    @Override
    public SysUser findSysUser(String username) {
        logger.info("请求认证的用户名:" + username);
        //1.通过请求的用户名去数据库中查询用户信息
        SysUser user = sysUserService.findByUsername(username);
        return user;
    }
}
